package GUI.studentGUI;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import GUI.MainGUI;
import controllers.StudentController;
import javax.swing.JLabel;
/**
 * 
 * the student main menu  
 
 */
public class StudentWindow extends JPanel implements ActionListener {

	
	private static final long serialVersionUID = 1L;
	private JButton btnNewExam;
	private JButton btnReports;
	private JButton btnExit;
	private JLabel lblWelcome;
	private StudentController StudentCtrl;

	public StudentWindow(StudentController StudentCtrl) {
		super();
		this.StudentCtrl = StudentCtrl;
		initialize();
	}

	private void initialize() {
		setBorder(new TitledBorder(null, "Student menu: ",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		setBackground(SystemColor.activeCaption);
		setBounds(0, 0, MainGUI.setX, MainGUI.setY);
		setLayout(null);
		add(GetBtnReports());
		add(GetBtnExit());
		add(GETgetnewexam());
		add(GETlblWelcome());

	}

	private JLabel GETlblWelcome() {
		if (lblWelcome == null) {
			lblWelcome = new JLabel("WELCOME");
			lblWelcome.setHorizontalAlignment(SwingConstants.CENTER);
			lblWelcome.setFont(new Font("Tahoma", Font.PLAIN, 30));
			lblWelcome.setBackground(SystemColor.inactiveCaptionBorder);
			lblWelcome.setBounds(-29, 31, 519, 89);
		}
		return lblWelcome;
	}

	private JButton GetBtnExit() {
		if (btnExit == null) {
			btnExit = new JButton("EXIT");
			btnExit.setSize(new Dimension(56, 32));
			btnExit.setLocation(417, 442);
			btnExit.setFont(new Font("Microsoft New Tai Lue ", Font.BOLD, 12));
			btnExit.setBorder(BorderFactory
					.createLineBorder(SystemColor.desktop));
			btnExit.addActionListener(this);
		}
		return btnExit;
	}

	private JButton GetBtnReports() {
		if (btnReports == null) {
			btnReports = new JButton("Reports");
			btnReports.setForeground(SystemColor.desktop);
			btnReports.setFont(MainGUI.PanelFont);
			btnReports.setBounds(99, 184, 282, 40);
			btnReports.addActionListener(this);
		}
		return btnReports;
	}

	private JButton GETgetnewexam() {
		if (btnNewExam == null) {
			btnNewExam = new JButton("Take exam");
			btnNewExam.setFont(new Font("Dialog", Font.BOLD, 12));
			btnNewExam.setBounds(99, 271, 282, 40);
			btnNewExam.addActionListener(this);
		}
		return btnNewExam;
	}

	@Override
	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == btnExit)
			StudentCtrl.handleStudentGUI(StudentController.EXIT);

		if (e.getSource() == btnReports) {
			StudentCtrl.handleStudentGUI(StudentController.REPORT);// go to
																	// student
																	// reports
		}
		if (e.getSource() == btnNewExam) {
			StudentCtrl.handleStudentGUI(StudentController.EXAM);
		}

	}
}